package com.patrick.open.api.core.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @author patrick
 * @date 2020/5/29 4:21 下午
 * @Des XSS攻击
 * 最簡單的事是堅持，最難的事還是堅持
 */
public class XssFilter implements Filter {
  @Override
  public void init(FilterConfig filterConfig) throws ServletException {

  }

  @Override
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
    throws IOException, ServletException {
    HttpServletRequest req = (HttpServletRequest) request;
    XssHttpServletRequestWrapper xssRequestWrapper = new XssHttpServletRequestWrapper(req);
    chain.doFilter(xssRequestWrapper, response);
  }

  @Override
  public void destroy() {

  }
}
